package com.accp.demo.controller.stock;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.accp.demo.pojo.stock.StockLedger;
import com.accp.demo.service.stock.StockLedgerService;

@Controller
@RequestMapping("/StockLedger")
public class StockLedgerController {
		
	@Autowired
	private StockLedgerService stockLedgerService;
	
	@RequestMapping(value="/insert",method=RequestMethod.POST)
	public void insert(@RequestBody StockLedger stockLedger){
		System.err.println("进入stockLedger的Controller的insert:"+stockLedger.toString());
		stockLedgerService.insert(stockLedger);
	}
	
	@RequestMapping("/delete")
	public void delete(@PathVariable int wareNo,String materialNo){
		System.err.println("进入stockLedger的Controller的delet:"+wareNo+"和"+materialNo);
		stockLedgerService.delete(wareNo, materialNo);
	}
	
	@RequestMapping("/update")
	public void update(@RequestBody StockLedger StockLedger){
		System.err.println("进入stockLedger的Controller的update:"+StockLedger);
		stockLedgerService.update(StockLedger);
	}
	
	@RequestMapping("/findByWNoAndWNo")
	@ResponseBody
	public StockLedger findByWNoAndWNo(@PathVariable int wareNo,String materialNo){
		System.err.println("进入stockLedger的Controller的find:"+wareNo+"和"+materialNo);
		
		return stockLedgerService.findByWareNoNoAndMaterialNo(wareNo, materialNo);
	}

}
